<extend name="Layout/page_popup" />
<block name="content">
{:W('PageHeader/simple',array('name'=>'请选择父节点','search'=>'N'))}
<div class="operate panel panel-default">
	<div class="panel-body">
		<div class="pull-left">
			<a  onclick="save();" class="btn btn-sm btn-primary">确定</a>
		</div>
		<div class="pull-right">
			<a  onclick="myclose();" class="btn btn-sm btn-primary">关闭</a>
		</div>
	</div>
	<div class="popup_tree_menu">
		<ul class="tree_menu">
			<li>
				<a node="0"><i class="icon"></i> <span>根节点</span> </a>
				{$menu}
			</li>
		</ul>
	</div>
</div>
<input type="hidden" name="val" id="val">
<input type="hidden" name="name" id="name">
</block>
<block name="js">
<script type="text/javascript">
	function save() {
		if ($("#name").val().length > 0) {
			$("#node_name", parent.document).val($("#name").val());
			$("#pid", parent.document).val($("#val").val());
		} else {
			ui_error("请选择节点");
			return false;
		}
		myclose();
	}


	$(document).ready(function() {
		parent_node = $(".sub_left_menu ul.tree_menu a.active", parent.document).attr("node");
		$("ul.tree_menu a[node='" + parent_node + "']").addClass("disabled");
		$(".popup_tree_menu a:not('.disabled')").click(function() {
			$("#val").val($(this).attr("node"));
			$("#name").val($(this).children("span").text());
			$(".tree_menu a.active").removeClass("active");
			$(this).addClass("active");
		})
	}); 
</script>
</block>